package com.ruoyi.merchant.controller;

import com.ruoyi.common.core.cg.pojo.Community;
import com.ruoyi.common.core.cg.result.Result;
import com.ruoyi.merchant.service.CommunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("community")
public class CommunityController {
    @Autowired
    private CommunityService service;

    /**
     * 查询周边社区
     * @param latitude 纬度
     * @param longitude 精度
     * @return
     */
    @RequestMapping("findNearCommunity")
    public Result findNearCommunity(BigDecimal latitude,BigDecimal longitude){
        try {
            List<Community> communityList = service.findNearCommunity(latitude,longitude);
            return new Result(true,"查询周边社区成功",communityList);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,"查询周边社区失败");
        }
    }
}
